package pl.model.domain;

import java.util.Collection;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

@Entity
public class Comment extends AbstractDBObject {

	protected String content;
	protected String author; // not logged, anonymous
	@ManyToOne
	protected User user; // logged user
	@ManyToOne
	protected Comment comment; // if null its main comment, else its reply to this
	@ManyToOne
	protected Book book; // if null, replyTo Comment mustn't be null, and it's
	// subcomment to another comment
	@OneToMany(mappedBy="comment")
	protected Collection<Comment> answers;

	@Override
	public String toString() {
		return super.toString() + " ";
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Comment getComment() {
		return comment;
	}

	public void setComment(Comment replyToComment) {
		this.comment = replyToComment;
	}

	public Book getBook() {
		return book;
	}

	public void setBook(Book replyToBook) {
		this.book = replyToBook;
	}

	public Collection<Comment> getAnswers() {
		return answers;
	}

	public void setAnswers(Collection<Comment> answers) {
		this.answers = answers;
	}
}
